﻿@using RiverCruise.Helpers
@model RiverCruise.Models.Ship.ShipAttachmentsModel

<div id="pagerTarget">

    @if (Model.Attachements.Any())
    {

        @Html.Partial("_Paging", Model)

        <div>
            @foreach (var attachment in Model.Attachements)
            {
                <hr />
                <div class="container-fluid">
                    <div class="col-md-1"><a href="@Url.Action("DownloadFile", "FileUpload", new { attachment.Id }, null)" target="_blank"><img src="~/Content/images/File.png" alt="file" /></a></div>
                    <div class="col-md-5">@Html.DisplayFor(model => attachment.Name)</div>
                    <div class="col-md-5">@Html.DisplayFor(model => attachment.Date)</div>

                    @if (User.IsInRole(RoleHelper.Edit))
                    {
                        <div class="col-md-1">
                            @using (Html.BeginForm("DeleteFile", "FileUpload", FormMethod.Post, new {data_rc_modalaction = "DeleteFileGet", data_rc_modalcontroller = "FileUpload", @class = "triggerModal"}))
                            {
                                @Html.AntiForgeryToken()
                                <input type="hidden" value="@attachment.Id" name="id" id="id" />
                                <button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-trash"></span></button>
                            }

                        </div>
                    }
                    
                </div>
            }
            <hr />
        </div>

        @Html.Partial("_Paging", Model)
    }
    else
    {
        <div class="row">
            <div class="col-md-8 col-md-offset-2">
                <div class="bs-callout bs-callout-warning text-warning">
                    <ul>
                        <li>No attachments available</li>
                    </ul>
                </div>
            </div>
        </div>
    }
</div>